<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js App" />
    <input type="text" value="Submit" v-on:input="onTextChange" />
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue';
import _ from 'loadsh';

function debounce(cb, wait = 1000) {
  debugger;
  console.log(this);
  // if (this.timer !== null) {
  //   clearTimeout(this.timer);
  // }
  // this.timer = setTimeout(() => {
  //   this.timer = null;
  //   cb && cb();
  // }, wait);
}

export default {
  name: 'App',
  components: {
    HelloWorld,
  },
  data: () => {
    return {};
  },
  methods: {
    onTextChange: function(e) {
      const text = e.target.value;
      // console.log(e);
      // debugger;
      _.debounce(() => console.log(text), 1000);
      // debounce.bind(this, () => console.log(text))();
      // debugger;
      debounce();
    },
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
